<script type="text/javascript" src="<?php echo $this->webroot.'/theme/default/u22';?>/js/ZeroClipboard.js"></script>
<script type="text/javascript" src="<?php echo $this->webroot.'/theme/admin/';?>js/admin.js"></script>
<style>
    #list_url{
        white-space:nowrap;
        overflow:hidden;
        text-overflow:ellipsis;/*以省略号替代截除部分*/
}
</style>
<script>
    var clip1 = null;

    $(document).ready(function() {
        change_menu_class('m_1');
        $("#short_url").html('');
        get_my_url_list(1);
    });

function get_my_url_list(page){
    var str_td = $("#list_first").html();
    //alert(str_td);
    
    $.ajax({
        url: "<?php echo url_for('servlet/my_url_list')?>/page/"+page,
        dataType:"json",
        type:"GET",
        success:function(data){
            if(data.code=='error'){
                alert(data.msg);
            }else if(data.code == 'ok' && data.data !=''){
                //$("#list_url").html(str_td);
                my_url_list(data.data);
                $("#pager_this").html(data.page);
            }
        },error:function(){
            
        }
    });
}

function my_url_list(data){
    var top = $("#list_first").html();
    top     = "<tr id='list_first'>"+top +"</tr>";
    var html_cache  = '';
    $.each(data, function(k,v){
        html_cache  += html_tr(v.uhash, v.sina_url, v.tencent_url, v.url,k,v.total_pv,v.total_ip);
    });
    $("#list_url").html(top+html_cache);
    set_copy(data);
//    $(".table > td").click(function(){
//        $("#loader_container").show();
//    });
    //load_copy();

}

function short_url(){
    var short_url = $("#short_url").val();
    $.ajax({
        url:"<?php echo url_for('servlet/add_url');?>",
        dataType:"json",
        type:"POST",
        data:{'url':short_url},
        success:function(data){
            if(data.code =='error'){
                alert(data.msg);
            }else if(data.code =='ok'){
                if(short_url.length >40) {
                    short_url   = short_url.substring(0,40);
                }
                html_tr(data.u22, data.sina, data.tencent, short_url);
            }else{
                alert(data);
            }
            $("#loader_container").hide();
        },error:function(){
            alert('请稍后再试');
        },beforeSend:function(){
            $("#loader_container").show();
            $("#loader_container_msg").html('正在加载中,请稍后...');
        }
    });
}

function postUrl() {
    $("#post_form").submit();
}


</script>
<div class="content">
    		<div class="shorten">
                    <form action="<?php echo url_for('api/post');?>" method="post" id="post_form">
                        <input type="hidden" value="user" name="back_url" />
                        <?php $msg  = getFlashMsg();
                        if(!$msg) {
                            $msg    = '输入需要缩短的网址';
                        }
                        ?>
                    <textarea name="url" cols="45" rows="5" class="text_area" id="short_url" onclick="short_url_clear();">输入需要缩短的网址</textarea>
                    </form>
                <div class="popup">
                	<div class="l"></div>
                	<div class="btnshort r"><a href="javascript:postUrl();">立即缩短</a></div>
                    <div class="c"></div>
                </div>
            </div>
            <div class="notic">
            	<h3>站点公告</h3>
            </div>
            <div class="history">
            	<h3>我的使用记录，最近30条<!--a href="#">查看全部>></a--></h3>
                <div class="list">
                    <table width="940" border="0" cellpadding="0" cellspacing="0" id="list_url">
                        <tr id="list_first">
                            <td bgcolor="#e4e4e4">今日访问</td>
                            <td colspan="1" bgcolor="#e4e4e4">短链接地址</td>
                            <td bgcolor="#e4e4e4">信息页</td>
                            <td bgcolor="#e4e4e4">原链接地址</td>
                            <!--td bgcolor="#e4e4e4">操作</td-->
                        </tr>
                    </table>
          	</div>
            	<div class="page r" id="pager_this"></div>
            </div>
        </div>